package com.clkj.zhonghui.dao.topic;

import com.clkj.zhonghui.pojo.topic.TopicComment;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;

/**
 * @Author：周佳润
 * @Date：2024/7/16 下午1:59
 */
public interface TopicCommentMapper extends Mapper<TopicComment>, MySqlMapper<TopicComment> {
    @Select("select b.*, a.topic_title as topicName from t_zh_topicComment b " +
            "JOIN t_zh_topic a ON a.topic_id = b.topic_id " +
            "where b.comment_flag = #{commentFlag} " +
            "and (#{topicId} is null or b.topic_id = #{topicId}) " +
            "order by comment_id desc")
    List<TopicComment> selectTopicComment(Integer commentFlag, Integer topicId);

    @Select("select b.*, a.user_name as userName,a.user_img as userImg from t_zh_topicComment b " +
            "JOIN t_zh_user a ON a.user_id = b.user_id " +
            "where b.topic_id = #{topicId} " +
            "order by comment_id desc")
    List<TopicComment> selectCommentByUser(Integer topicId);
}
